﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLK.Database.DALs;

namespace QLK.Database.BLLs
{
   public class ProductBLL
    {
        private ProductDAL dal;

        public ProductBLL()
        {
            dal = new ProductDAL();
        }

        public Product ProductGetByID(int productID)
        {
            if (productID > 0)
                return dal.ProductGetByID(productID);
            return null;
        }

        public List<Product> ProductGetAll()
        {
            return dal.ProductGetAll();
        }

        public bool ProductDeleteByID(int productID)
        {
            return dal.ProductDeleteByID(productID);
        }

        public bool ProductUpdate(Product Prods)
        {
            return dal.ProductUpdate(Prods);
        }

        public bool ProductInsert(Product Prods)
        {
            //Check duplicate UPC
            if (dal.ProductCheckDuplicateUPC(Prods.UPC))
                return dal.ProductInsert(Prods);
            return false;
        }

        public List<Product_GetForSearchResult> ProductGetForGrid()
        {
            return dal.ProductGetForGrid();
        }

        public List<Product_GetForSearchByProductNameResult> ProductGetByProductName(string ProName)
        {
            return dal.ProductGetByProductName(ProName);
        }

        public List<Product_GetForSearchByUPCResult> ProductGetByUPC(string UPC)
        {
            return dal.ProductGetByUPC(UPC);
        }

        public List<Product_GetForSearchByCategoryIDResult> ProductGetByCateID(int CateID)
        {
            return dal.ProductGetByCateID(CateID);
        }

        public List<Product_GetForSearchByManuIDResult> ProductGetByManuID(int ManuID)
        {
            return dal.ProductGetByManuID(ManuID);
        }

        public List<Product_GetForSearchByPriceResult> ProductGetByPrices(int PriceFrom, int PriceTo)
        {
            return dal.ProductGetByPrices(PriceFrom, PriceTo);
        }
    }
}
